//
//  MicroBlogModel.m
//  MicroBlog
//
//  Created by cocoazxj@163.com on 15/3/29.
//  Copyright (c) 2015年 handcool. All rights reserved.
//

#import "MicroBlogModel.h"

@implementation MicroBlogModel

- (instancetype)initWithDict:(NSDictionary *)dict
{
    if(self =[super init])
    {
        self.icon = dict[@"icon"];
        self.name = dict[@"name"];
        self.content = dict[@"text"];
        self.vip = [dict[@"vip"] stringValue];
    }
    return self;
}

+ (instancetype)microBlog:(NSDictionary *)dict
{
    return [[self alloc] initWithDict:dict];
}

-(CGFloat)nameH
{
    NSDictionary *d = @{NSFontAttributeName : [UIFont systemFontOfSize:14]};
    CGFloat f = [self.name boundingRectWithSize:CGSizeMake(100, 20) options:NSStringDrawingUsesLineFragmentOrigin attributes:d context:nil].size.height;
    _nameH = f;
    return _nameH;
}
-(CGFloat )pictureH
{
    
    _pictureH = 60;
    return _pictureH;
}
-(CGFloat)contentH
{
    NSDictionary *d = @{NSFontAttributeName : [UIFont systemFontOfSize:14]};
    CGFloat f = [self.content boundingRectWithSize:CGSizeMake(300, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:d context:nil].size.height;
    _contentH = f;
    return _contentH;
}
- (CGFloat)cellH
{
    _cellH = self.nameH + self.pictureH + self.contentH;
    return _cellH;
}
@end
